/*
 * datastructures.h
 *
 *  Created on: Sep 26, 2013
 *      Author: cinus
 */

#ifndef DATASTRUCTURES_H_
#define DATASTRUCTURES_H_
#include <stdlib.h>
#include <stddef.h>

#include "types.h"
#include "settings.h"

struct netdata;

struct neuron {

	float32 z; //output
	float32 a; //sum of inputs
	float32 delta;
	//float32 gradient;

	float32* gradient;
	float32* gradientP;
	float32* deltaWeights;
	float32* deltaWeightsP;
	float32* ipropDelta;
	float32* ipropDeltaP;
	float32* weights; //outgoing weights

	float32 (*activationFunction)(struct netdata*, float32 x);//typedef is not yet known
	float32 (*diffActivationFunction)(struct netdata*, float32 x);

	uint32 n_input;
	uint32 n_output;

	struct neuron** inputs;
	struct neuron** outputs;

	uint32 layer;//used by the copy algorithm
	uint32 pos;//used by the copy algorithm
};

typedef struct neuron neuron_t;
typedef neuron_t* neuron_tp;

struct netdata {
	uint32 layersize;
	uint32 *neurons;
	uint32 colums;
	neuron_tp neuron_matrix;
	settings_t settings;
	float32 error;
	float32 lastError;
	float32 (*errorComputation)(float32 *output, float32 *target, size_t size);
	void (*computeDeltaWeights)(struct netdata* net, neuron_tp self);
};

typedef struct netdata netdata_t;

typedef netdata_t* netdata_tp;

#endif /* DATASTRUCTURES_H_ */
